﻿using System;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Web.UI;

namespace SmartHRMS.UI.Web
{
    public partial class MasterPage : System.Web.UI.MasterPage
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string pageCssClass = (Page.GetType().Name + " Loading");
                PropertyInfo p = Page.GetType().GetProperty("CssClass");
                if (null != p)
                {
                    string cssClassName = ((string)(p.GetValue(Page, null)));
                    if (!(String.IsNullOrEmpty(pageCssClass)))
                        pageCssClass = (pageCssClass + " ");
                    pageCssClass = (pageCssClass + cssClassName);
                }
                if (!(pageCssClass.Contains("Wide")))
                    pageCssClass = (pageCssClass + " Standard");
                LiteralControl c = ((LiteralControl)(Page.Form.Controls[0]));
                if ((null != c) && !(String.IsNullOrEmpty(pageCssClass)))
                    c.Text = Regex.Replace(c.Text, "<div>", String.Format("<div class=\"{0}\">", pageCssClass));
            }
        }
    }
}